package cn.yi.newsys.service.impl;

import java.util.List;

import cn.yi.newsys.dao.NewsCategoryDao;
import cn.yi.newsys.dao.impl.NewsCategoryDaoImpl;
import cn.yi.newsys.pojo.NewsCategory;
import cn.yi.newsys.service.NewsCategoryService;

public class NewsCategoryServiceImpl implements NewsCategoryService{

	private NewsCategoryDao ncd = new NewsCategoryDaoImpl() ;
	
	@Override
	public List<NewsCategory> showAllNewsCategory() {
		return ncd.getAllNewsCategory() ;
	}

	@Override
	public NewsCategory getNewsCategoryByID(int id) {
		return ncd.getNewsCategoryByID(id) ;
	}

	@Override
	public NewsCategory getNewsCategoryByName(String name) {
		// TODO Auto-generated method stub
		return ncd.getNewsCategoryByName(name) ;
	}

	@Override
	public int addNewsCategory(NewsCategory nc) {
		int num = -1 ;
		NewsCategory nc2 = ncd.getNewsCategoryByName(nc.getName()) ;
		if(nc2 == null){
			num = ncd.addNewsCategory(nc) ;	
		}
		return num ;
	}

}
